#!/bin/bash

#get apk installed path
performenc_test_tool_package_name=`adb shell pm list package -3 | gawk -F: '/.*(com.htc.wavevr.platform_perf_certif_tool)$/{print $2;}'`
performence_test_tool_base_apk_path=`adb shell pm path $performenc_test_tool_package_name | gawk -F: '/^(package).*/{print $2;}'`
performence_test_tool_install_path=${performence_test_tool_base_apk_path%/base.apk}
lib_path=$performence_test_tool_install_path/lib/arm

#backup 2.1.8 *.so archive
current_time=`adb shell date "+%y_%m_%d_%H_%M_%S"`
mkdir ${current_time}_2.1.8_so_bak

adb pull $lib_path/liboverlay_common_api.so $current_time_2.1.8_so_bak
adb pull $lib_path/libsvrapi.so $current_time_2.1.8_so_bak
adb pull $lib_path/libvrcore.so $current_time_2.1.8_so_bak
adb pull $lib_path/libwvr_api.so $current_time_2.1.8_so_bak
adb pull $lib_path/libwvr_ctf_internal_common.so $current_time_2.1.8_so_bak
adb pull $lib_path/libwvr_monitor.so $current_time_2.1.8_so_bak

echo -e "------push *.so start------\n"
adb push liboverlay_common_api.so $lib_path
adb push libsvrapi.so $lib_path
adb push libvrcore.so $lib_path
adb push libwvr_api.so $lib_path
adb push libwvr_ctf_internal_common.so $lib_path
adb push libwvr_monitor.so $lib_path
echo -e "\n-------push *.so end---------"

performence_test_tool_pid=`adb shell ps | gawk '/.*(com\.htc\.wavevr\.platform_perf_certif_tool)$/{print $2}'`
echo -e "performence test tool pid is:$performence_test_tool_pid, kill it\n"
adb shell kill -s 9 $performence_test_tool_pid
